Skip to content

[CLI-323] Added Supplier<T> defaults for getParsedOptionValue#229

Merged
garydgregory merged 5 commits into
apache:masterfrom
Claudenw:CLI-323_Supplier_for_getParsedOptionValue
Feb 16, 2024
Merged

[CLI-323] Added Supplier<T> defaults for getParsedOptionValue#229
garydgregory merged 5 commits into
apache:masterfrom
Claudenw:CLI-323_Supplier_for_getParsedOptionValue

Conversation

@Claudenw

@Claudenw Claudenw commented Feb 8, 2024

Copy link
Copy Markdown
Contributor

@Claudenw Claudenw changed the title Added Supplier<T> defaults for getParsedOptionValue CLI-323: Added Supplier<T> defaults for getParsedOptionValue Feb 8, 2024
@Claudenw Claudenw requested a review from garydgregory February 8, 2024 11:48

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Claudenw
Thank you for your PR.
You'll need to add tests to cover the new feature.

@Claudenw

Copy link
Copy Markdown
Contributor Author

I think I have this fixed now.

Comment thread src/main/java/org/apache/commons/cli/CommandLine.java Outdated

try {
return res == null ? defaultValue : (T) option.getConverter().apply(res);
return res == null ? defaultValue.get() : (T) option.getConverter().apply(res);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Claudenw
You're missing a test for when defaultValue is null.


assertEquals(123, ((Number) cmd.getParsedOptionValue(optI)).intValue());
assertEquals("foo", cmd.getParsedOptionValue(optF, "foo"));
assertEquals("foo", cmd.getParsedOptionValue(optF, ()-> "foo"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

() -> ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you know how to fix the checkstyle to look for this error I would appreciate it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you know how to fix the checkstyle to look for this error I would appreciate it.

Hi @Claudenw
Done. Please rebase on git master.

@Claudenw Claudenw self-assigned this Feb 15, 2024

@garydgregory garydgregory left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Claudenw
TY for your updates. Please see my comment.

Comment thread src/test/java/org/apache/commons/cli/CommandLineTest.java
@codecov-commenter

codecov-commenter commented Feb 16, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.11%. Comparing base (9f6b23b) to head (c36c7f7).
Report is 271 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #229      +/-   ##
============================================
+ Coverage     91.90%   92.11%   +0.21%     
- Complexity      575      586      +11     
============================================
  Files            22       22              
  Lines          1247     1255       +8     
  Branches        210      212       +2     
============================================
+ Hits           1146     1156      +10     
+ Misses           63       61       -2     
  Partials         38       38              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Claudenw Claudenw force-pushed the CLI-323_Supplier_for_getParsedOptionValue branch from 4f53cba to c36c7f7 Compare February 16, 2024 14:08
@garydgregory garydgregory changed the title CLI-323: Added Supplier<T> defaults for getParsedOptionValue [CLI-323] Added Supplier<T> defaults for getParsedOptionValue Feb 16, 2024
@garydgregory garydgregory merged commit 8eb7b89 into apache:master Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants